package com.person.webdemoproject2.controller;

import com.person.webdemoproject2.pojo.Result;
import com.person.webdemoproject2.pojo.UserRelationship;
import com.person.webdemoproject2.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@CrossOrigin
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping("/follow")
    public Result userrelation(@RequestBody UserRelationship userRelationship , @RequestHeader String token) {

        log.info("用户选择关注人 {}",userRelationship.getFusername());

        boolean follow = userService.follow(userRelationship, token);

        if (follow) {
            return Result.success(true);
        }

        return Result.success(false);
    }}
